#include <stdio.h>

struct _DateTime
{
    int hour;
    int minute;
    int second;
};
typedef struct _DateTime DateTime;

void addSecond(DateTime * t) {
    t->second++;
    if (t->second >= 60)
    {
        t->second=0;
        t->minute++;
    }
    if (t->minute >= 60)
    {
        t->minute=0;
        t->hour++;
    }
}

void testStructDataTime() {
    DateTime times[3] = {
        {11, 11, 11},
        {11, 59, 59},
        {11, 11, 59},
    };

    for (int i = 0; i < sizeof(times)/sizeof(DateTime); i++)
    {
        printf("%d:%d:%d ", times[i].hour, times[i].minute, times[i].second);
        addSecond(&times[i]);
        printf(" After Second => %d:%d:%d\n", times[i].hour, times[i].minute, times[i].second);
    }
    
}


typedef struct point
{
    int x;
    int y;
} Point;


struct point * scanfPoint(struct point * p) {
    printf("输入x:\n");
    scanf("%d", &p->x);
    printf("输入y:\n");
    scanf("%d", &p->y);
    return p;
}

void printPoint(struct point p) {
    printf("x=%d, y=%d\n", p.x, p.y);
}

void testStructPoint() {
    struct point p = {.x=0, .y=0};
    scanfPoint(&p);
    printPoint(p);
    *scanfPoint(&p) = (struct point){123123,1231231};
    printPoint(p);
}


/**
 * @brief 结构体是赋值是创建一个新的结构体数据
 * 
 */
void simpleTestArr() {
    Point p = (Point){
        12,12
    };
    Point p2 = p;
    p2.x = 111;
    printf("p.x = %d\n", p.x);
    printf("address of p = %p\n", &p);
    printf("address of p2 = %p\n", &p2);

    Point ps[] = {
        {12,12}
    };

    Point p3 = ps[0];
    p3.x = 111000;

    printf("ps[0].x = %d\n", ps[0].x);

    Point *p4 = ps;
    *p4->x = 111323;
    printf("ps[0].x = %d\n", ps[0].x);

}

int main() {
    // testStructDataTime();
    simpleTestArr();
    return 0;
}